package day_2022_12_to_3.day;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author haomin
 * @date 2022/12/20 23:02
 **/
public class Day12_20_Num1760 {
    class Solution {
        public int minimumSize(int[] nums, int maxOperations) {
            int left = 1, right = Arrays.stream(nums).max().getAsInt();
            int ans = 0;
            while (left <= right) {
                int y = (left + right) / 2;
                long ops = 0;
                for (int x : nums) {
                    ops += (x - 1) / y;
                }
                if (ops <= maxOperations) {
                    ans = y;
                    right = y - 1;
                } else {
                    left = y + 1;
                }
            }
            return ans;
        }
    }
}